package logic

import (
	"context"
	"videos/model/mysql"

	"videos/videorpc/internal/svc"
	"videos/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CommentShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCommentShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentShowLogic {
	return &CommentShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CommentShowLogic) CommentShow(in *videorpc.CommentShowRequest) (*videorpc.CommentShowResponse, error) {
	// todo: add your logic here and delete this line

	var comment mysql.CommentUser

	err := comment.CommentShow(mysql.DB, in.CommentId)
	if err != nil {
		return nil, err
	}

	return &videorpc.CommentShowResponse{
		CommentId: int64(comment.CommentId),
		Content:   comment.Content,
		CreatedAt: comment.CreatedAt,
		NickName:  comment.NickName,
	}, nil
}
